#pragma once

#include <mcp/version.h>

// Platform detection
#if defined(_WIN32) || defined(_WIN64)
    #define MCP_PLATFORM_WINDOWS
#elif defined(__linux__)
    #define MCP_PLATFORM_LINUX
#elif defined(__APPLE__)
    #define MCP_PLATFORM_MACOS
#endif

// Compiler feature detection
#if defined(__cplusplus) && __cplusplus >= 202002L
    #define MCP_HAS_CPP20
#endif

#if defined(__cpp_coroutines) && __cpp_coroutines >= 201902L
    #define MCP_HAS_COROUTINES
#endif

// Export macros
#ifdef MCP_BUILD_SHARED
    #ifdef MCP_PLATFORM_WINDOWS
        #define MCP_API __declspec(dllexport)
    #else
        #define MCP_API __attribute__((visibility("default")))
    #endif
#else
    #ifdef MCP_PLATFORM_WINDOWS
        #define MCP_API __declspec(dllimport)
    #else
        #define MCP_API __attribute__((visibility("default")))
    #endif
#endif

#define MCP_NO_EXPORT

// Deprecation macro
#ifdef __has_cpp_attribute
    #if __has_cpp_attribute(deprecated)
        #define MCP_DEPRECATED(msg) [[deprecated(msg)]]
    #endif
#endif
#ifndef MCP_DEPRECATED
    #define MCP_DEPRECATED(msg)
#endif

// Force inline macro
#ifdef MCP_PLATFORM_WINDOWS
    #define MCP_FORCE_INLINE __forceinline
#else
    #define MCP_FORCE_INLINE inline __attribute__((always_inline))
#endif

// Noexcept helpers
#define MCP_NOEXCEPT noexcept
#define MCP_NOEXCEPT_EXPR(expr) noexcept(expr)

// Assertion macro
#ifndef NDEBUG
    #define MCP_ASSERT(cond) assert(cond)
#else
    #define MCP_ASSERT(cond) ((void)0)
#endif

#include <memory>

// C++11 compatibility utilities
namespace std {
    template<typename T, typename... Args>
    std::unique_ptr<T> make_unique(Args&&... args) {
        return std::unique_ptr<T>(new T(std::forward<Args>(args)...));
    }

    // nullopt for optional
    struct nullopt_t {
        explicit nullopt_t() {}
        nullopt_t(const nullopt_t&) {}
    };

    const nullopt_t nullopt{};
}

// Forward declarations for standard library types
namespace std {
    // Remove conflicting forward declarations
}